package com.chinaoly.sdk.image;

import android.databinding.BindingAdapter;
import android.widget.ImageView;

public class ImageBindingAdapter {

    /**
     * @param iv
     * @param imageUrl           图片url
     * @param radius             圆角图片的半径
     * @param isRound            是不是圆形图片
     * @param isDecolor          要不要去色
     * @param blurRadius         高斯模糊半径
     * @param blurSampling       高斯模糊取样点
     * @param left_top_radiu
     * @param right_top_radiu
     * @param left_bottom_radiu
     * @param right_bottom_radiu
     * @param placeHolder        资源加载过程中的图
     * @param fallback           空图
     * @param error              加载失败图
     * @param asBitmap
     * @param asGif
     * @param crossFade          图片渐显时间
     * @param centerCrop         缩放方式为centerCrop
     * @param centerInside       缩放方式为centerInside
     * @param fitCenter          缩放方式为fitCenter
     */
    @BindingAdapter(value = {"chinaoly:imageUrl", "chinaoly:radius", "chinaoly:isRound", "chinaoly:isDecolor",
            "chinaoly:blurRadius", "chinaoly:blurSampling",
            "chinaoly:left_top_radiu", "chinaoly:right_top_radiu", "chinaoly:left_bottom_radiu", "chinaoly:right_bottom_radiu",
            "chinaoly:placeHolder", "chinaoly:fallback", "chinaoly:error", "chinaoly:asBitmap", "chinaoly:asGif",
            "chinaoly:crossFade", "chinaoly:centerCrop", "chinaoly:centerInside", "chinaoly:fitCenter"}, requireAll = false)
    public static void loadImage(ImageView iv, String imageUrl, int radius, boolean isRound, boolean isDecolor, int blurRadius, int blurSampling,
                                 int left_top_radiu, int right_top_radiu, int left_bottom_radiu, int right_bottom_radiu,
                                 int placeHolder, int fallback, int error,
                                 boolean asBitmap, boolean asGif, int crossFade,
                                 boolean centerCrop, boolean centerInside, boolean fitCenter) {
        ImageManager.getInstance().loadImage(iv, imageUrl, radius, isRound, isDecolor, blurRadius, blurSampling,
                left_top_radiu, right_top_radiu, left_bottom_radiu, right_bottom_radiu,
                placeHolder, fallback, error, asBitmap, asGif, crossFade,
                centerCrop, centerInside, fitCenter, null);
    }


}